package LinhDB2.Day01;

import java.util.Scanner;

public class Assignment_7 {

	public static void main(String[] args) {
		Scanner k = new Scanner(System.in);
		double a;
		double b;
		double c;
		double delta;
		
		System.out.print("Please input a : ");
		a = k.nextDouble();
		System.out.print("Please input b : ");
		b = k.nextDouble();
		System.out.print("Please input c : ");
		c = k.nextDouble();
		
		if (a == 0) {
			if (b == 0) {
				if (c == 0) {
					System.out.println("Phuong trinh vo so nghiem");
				} else {
					System.out.println("Phuong trinh vo nghiem");
				}
			} else {
				System.out.println("Phuong trinh co nghiem x = " + (-c / (2 * b)));
			}
		} else {
			delta = Math.pow(b, 2) - 4 * a * c;
			if (delta < 0) {
				System.out.println("Phuong trinh vo nghiem");
			} else {
				if (delta == 0) {
					System.out.println("Phuong trinh co nghiem kep x1 = x2 = " + (-b / (2 * a)));
				} else {
					System.out.println("Phuong trinh co 2 nghiem :");
					System.out.println("\tx1 = \t" + ((-b - Math.sqrt(delta)) / (2 * a)));
					System.out.println("\tx2 = \t" + ((-b + Math.sqrt(delta)) / (2 * a)));
				}
			}
		}

	}

}
